package com.w2cx.selenium.business;

import com.w2cx.selenium.base.DriverBase;
import com.w2cx.selenium.operate.OpreatPositionManageOpreate;

public class OpreatPositionManageProcess {

    DriverBase driver;
    OpreatPositionManageOpreate opmo;
    public OpreatPositionManageProcess(DriverBase driver){
        this.driver = driver;
        opmo = new OpreatPositionManageOpreate(driver);
    }


    //添加运营位
    public void addOpreatePosition(String title){
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        opmo.clickOpreatManageMenu();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        opmo.clickOpreatPositionManageMenu();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        opmo.clickContentManageLink();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        opmo.clickAddBtn();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        opmo.inputTitle(title);
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        opmo.clickLinkTargetDownList();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        opmo.selectLinkTargetOption();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }


        opmo.clickConfirmBtn();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    //断言
    public boolean addPoreatePositionSuccess(String title){
        if(opmo.getFirstElementTitle().getText().contains(title)){
            return true;
        }else {
            return false;
        }
    }

    //删除运营位
    public void delPosition(String title){
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        //删除按钮
        opmo.clickDelBtn();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }

        //确定删除
        opmo.clickDelConfirmBtn();
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }


    //判断是否删除成功
    public boolean delPositionSuccess(String title) {
        if (opmo.getFirstElementTitle().getText().equals(title)) {
            return false;
        } else {
            return true;

        }
    }
}
